home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / edit / paint.zip / PIXEL.PAS < prev    next >
Pascal/Delphi Source File  |  1987-11-18  |  1KB  |  39 lines

  1. {  PIXEL is a set of low-level graphic primitives. }
  2.  
  3. procedure HiRes;    { enter HiRes graphics mode }
  4.     begin
  5.         inline (       (* uses interupt 10H in BIOS *)
  6.             $B8/$06/$00/   (* MOV  AX,6H   ;load fn # in A  *)
  7.             $CD/$10        (* INT  10H                      *)
  8.          );
  9.     end;
  10.  
  11. procedure Alfa;    { enter 80x25 alpha mode }
  12.     begin
  13.         inline (       (* uses interupt 10H in BIOS *)
  14.             $B8/$02/$00/   (* MOV  AX,2H   ;load fn # in A  *)
  15.             $CD/$10        (* INT  10H                      *)
  16.          );
  17.     end;
  18.  
  19. procedure pixel ( x,y,val : integer );
  20.                     { draw a pixel at <x,y>. If val=0,
  21.                       then erase the pixel instead.    }
  22.     type  mask = array [0..7] of byte;
  23.     const MASK1: mask =($80,$40,$20,$10,$08,$04,$02,$01);
  24.           MASK0: mask =($7F,$BF,$DF,$EF,$F7,$FB,$FD,$FE);
  25.           PIXBASE = $B800;
  26.     var   odd, bytA : integer;
  27.           point : ^byte;
  28.  
  29.     begin
  30.         { First compute a pointer to the byte containing pixel }
  31.         odd := y mod 2;    (* odd or even scan line? *)
  32.         bytA:= y div 2 * 80  +  x div 8  +  8192*odd;
  33.         point := ptr ( PIXBASE, bytA );
  34.  
  35.         { Now write the pixel into the byte  }
  36.         if  val=0  then point^ := point^ and MASK0 [x mod 8]
  37.         else            point^ := point^ or  MASK1 [x mod 8];
  38.     end;
  39.